//
//  TypeSettingViewController.m
//  VVProjectHelper
//
//  Created by admin on 2022/4/29.
//

#import "TypeSettingViewController.h"
#import "VVMAnchorTypesettingLayout.h"

#define UIColorFromRGB(rgbValue) [UIColor colorWithRed:((float)((rgbValue & 0xFF0000) >> 16))/255.0 green:((float)((rgbValue & 0xFF00) >> 8))/255.0 blue:((float)(rgbValue & 0xFF))/255.0 alpha:1.0]


@interface TypeSettingViewController ()<UICollectionViewDataSource, UICollectionViewDelegate>

@property (nonatomic, strong) UICollectionView *collectionView;

@end

@implementation TypeSettingViewController

- (UIModalPresentationStyle)modalPresentationStyle {
    return UIModalPresentationFullScreen;
}
- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    VVMAnchorTypesettingLayout *layout = [VVMAnchorTypesettingLayout new];
    layout.type = VVMAnchorTypesettingTwoAndTwo;
    layout.top = 100;
    _collectionView = [[UICollectionView alloc] initWithFrame:self.view.bounds collectionViewLayout:layout];
    _collectionView.dataSource = self;
    _collectionView.delegate = self;
    [_collectionView registerClass:[UICollectionViewCell class]
        forCellWithReuseIdentifier:@"xxx"];
    [self.view addSubview:_collectionView];
    
//    [NSTimer scheduledTimerWithTimeInterval:1 repeats:YES block:^(NSTimer * _Nonnull timer) {
//        layout.type = arc4random()%7;
//    }];
}


#pragma mark - collection

- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section {
    return 8;
}
- (__kindof UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
    
    UICollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"xxx" forIndexPath:indexPath];
    cell.backgroundColor = UIColorFromRGB(arc4random());
    
    return cell;
}


@end
